<%
=begin
apps: sonarqube
platforms: kubernetes, tanzu-application-catalog
id: enable_metrics
title: Enable metrics
category: administration
weight: 20
highlight: 20
=end %>

The chart can optionally start a sidecar exporter for [Prometheus](https://prometheus.io/) to expose JMX metrics. The metrics endpoint is exposed in a separate service.

To start the sidecar Prometheus exporter, set the *metrics.jmx.enabled* parameter to *true* when deploying the chart. Refer to the chart parameters for the default port number.

Metrics can be scraped from within the cluster using any of the following approaches:

* Adding the required annotations in the service for Prometheus to discover the metrics endpoints, as in the example below:

        metrics:
          jmx:
            service:
              annotations:
                prometheus.io/scrape: "true"
                prometheus.io/port: "10443"
                prometheus.io/path: "/"

* Creating a ServiceMonitor (when the Prometheus Operator is available in the cluster). You can do this setting the *metrics.serviceMonitor.enabled* parameter to *true* when deploying the chart.
* Using something similar to the [example Prometheus scrape configuration](https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml).

If metrics are to be scraped from outside the cluster, the Kubernetes API proxy can be utilized to access the endpoint.

